import { View } from "../../../mvc/core/View";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
import { GButton } from "../../../../com/mui/controls/GButton";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ParamsConst } from "../../../common/global/ParamsConst";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { KeyCode } from "../../../../com/gengine/keyBoard/KeyCode";
import { ShopMallEventName } from "./ShopMallEventName";
import { SMoney } from "../../../../Message/Game/SMoney";
import { MoneyUtil } from "../common/util/MoneyUtil";
import { TextBox } from "../pack/TextBox";
type int = number;
//class BottomPanel
    
    export  class BottomPanel extends View
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public init(): void
        {
            this._pointTip = new GLabel();
            this._pointTip.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._pointTip.htmlText = HTMLUtil.addColor(Language.getString(53003), "#ffea00");
            this._pointTip.visible = false;
            this._pointTip.y = this._y;
            this.addChild(this._pointTip);
            this._searchText = new GTextInput();
            this._searchText.setStyle("textPadding", 3);
            this._searchText.name = "SearchText";
            this._searchText.styleName = "GTextInput";
            this._searchText.width = 117;
            this._searchText.height = 22;
            this._searchText.htmlText = "";
            this._searchText.addEventListener(flash.events.KeyboardEvent.KEY_DOWN, this.onSearchTextKeyDown);
            this.addChild(this._searchText);
            this._searchBtn = new GButton();
            this._searchBtn.label = Language.getString(53004);
            this._searchBtn.name = "SearchButton";
            this._searchBtn.styleName = "Button";
            this._searchBtn.width = 49;
            this._searchBtn.height = 28;
            this._searchBtn.x = 119;
            this._searchBtn.y = -3;
            this.addChild(this._searchBtn);
            this.pageBar = new PageSelecter();
            this.pageBar.move(190, this._y);
            this.addChild(this.pageBar);
            this._ingot = GlobalClass.getBitmap(ImagesConst.Yuanbao);
            this._ingot.x = 310;
            this._ingot.y = this._y;
            this.addChild(this._ingot);
            this._goldTxt = ObjCreate.createTextField("", 340, this._y, 60, 20, this, GlobalStyle.textFormat6);
            this._goldTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._lockIngot = GlobalClass.getBitmap(ImagesConst.Yuanbao_bind);
            this._lockIngot.x = 395;
            this._lockIngot.y = this._y;
            this.addChild(this._lockIngot);
            this._glodBindTxt = ObjCreate.createTextField("", 425, this._y, 60, 20, this, GlobalStyle.textFormat6);
            this._glodBindTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._pointBitmap = GlobalClass.getBitmap(ImagesConst.PointSmall);
            this._pointBitmap.x = 485;
            this._pointBitmap.y = this._y;
            this.addChild(this._pointBitmap);
            this._pointTxt = ObjCreate.createTextField("", 505, this._y, 60, 20, this, GlobalStyle.textFormat6);
            this._pointTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            if (ParamsConst.isPay) 
            {
                this._rechargeBtn = new GButton();
                this._rechargeBtn.x = 550;
                this._rechargeBtn.y = -5;
                this._rechargeBtn.setSize(77, 28);
                this._rechargeBtn.name = "RechargeButton";
                this._rechargeBtn.label = Language.getString(53005);
                this._rechargeBtn.styleName = "ButtonRed";
                this._rechargeBtn.drawNow();
                this._rechargeBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onRechargeBtnClick);
                (this._rechargeBtn.getChildAt(1) as Object /* flash.text.TextField */).filters = [FilterConst.nameGlowFilter];
                this.addChild(this._rechargeBtn);
            }
            this.showMoney(true);
            return;
        }

        public onRechargeBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GotoPay));
            return;
        }

        /* internal  */onSearchTextKeyDown(arg1: Object /* flash.events.KeyboardEvent */): void
        {
            if (arg1.keyCode == KeyCode.ENTER) 
            {
                this.dispatchEvent(new DataEvent(ShopMallEventName.SEARCH_ENTER, null, false, true));
            }
            arg1.stopImmediatePropagation();
            return;
        }

        public updateMoney(arg1: SMoney): void
        {
            this._goldTxt.htmlText = MoneyUtil.getGoldHtml(arg1.gold);
            this._glodBindTxt.htmlText = MoneyUtil.getGoldHtml(arg1.goldBind);
            this._pointTxt.htmlText = MoneyUtil.getGoldHtml(arg1.point);
            return;
        }

        public updatePage(arg1: int=0, arg2: int=0): void
        {
            this._pageText.htmlText = Language.getStringByParam(53006, arg1, arg2);
            return;
        }

        public get searchText(): GTextInput
        {
            return this._searchText;
        }

        public set searchText(arg1: GTextInput)
        {
            this._searchText = arg1;
            return;
        }

        public showMoney(arg1: Boolean): void
        {
            return;
        }

        public showPointTip(arg1: Boolean): void
        {
            if (arg1) 
            {
                this._pointTip.visible = true;
                this._searchText.visible = false;
                this._searchBtn.visible = false;
            }
            else 
            {
                this._pointTip.visible = false;
                this._searchText.visible = true;
                this._searchBtn.visible = true;
            }
            return;
        }

        /* internal */ /* var */_pointTip: GLabel;

        /* internal */ /* var */_searchText: GTextInput;

        /* internal */ /* var */_searchBtn: GButton;

        /* internal */ /* var */_pageText: TextBox;

        /* internal */ /* var */_ingot: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_lockIngot: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_goldTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_glodBindTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_pointBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_pointTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_rechargeBtn: GButton;

        public /* var */pageBar: PageSelecter;

        /* internal */ /* var */_y: int=5;
    }
